import sys
import cv2
import face_recognition

def faceDuibi():
	# 1发现
	face_image1 = face_recognition.load_image_file(r'img/all.png')
	face_image2 = face_recognition.load_image_file(r'test.png')
	
	# 2特征提取
	# 有多少人，就有多少条数据（数组
	face_encodings1 = face_recognition.face_encodings(face_image1)
	face_encodings2 = face_recognition.face_encodings(face_image2)
	# 人脸定位四个方向点
	face_locations = face_recognition.face_locations(face_image1)
	print(face_locations,end="---------")
	# print(face_encodings1,face_encodings2)
	for i in range(len(face_encodings1)):
		face1 = face_encodings1[i-1]
		face2 = face_encodings2[0]
		results = face_recognition.compare_faces([face1],face2,tolerance=0.5)
		if results == [True] :
			# print("与第",i+1,"个人匹配2）")
			face_location = face_locations[(i-1)]
			top,right,bottom,left = face_location
			cv2.rectangle(face_image1,(left,top),(right,bottom),(0,255,0),2)
			face_image_rgb = cv2.cvtColor(face_image1,cv2.COLOR_BGR2RGB)
			# cv2.imshow("图像对比",face_image_rgb)
			# cv2.waitKey(0)
			return face_image_rgb
		else :
			print("与第",i+1,"个人不匹配")